package com.krstin.designpattern.ocp.improve;

import org.w3c.dom.css.Rect;

public class Ocp {

    public static void main(String[] args) {
        new DrawUtil().draw(new Circle());
        new DrawUtil().draw(new Rectangle());
        new DrawUtil().draw(new Tringle());

    }

}

class DrawUtil {

    public void draw(Shape shape) {
        shape.draw();
    }

}

abstract class Shape {

    abstract public void draw();

}

class Circle extends  Shape {

    public void draw() {
        System.out.println(" 绘制圆形");
    }
}


class Rectangle extends  Shape {

    public void draw() {
        System.out.println(" 绘制矩形");
    }
}

class Tringle extends  Shape {

    public void draw() {
        System.out.println(" 绘制三角形");
    }
}